import Request from './request.js'


const API = {
	queryList: '/app/bus/recommend/services',
	getServiceByArea: '/app/bus/sevItem/getServiceByArea',
	getSevItemList: '/app/bus/sevItem/getSevItemList',
	getSevItemInfo: '/app/bus/sevItem/getSevItemInfo/{id}',
	getBannerList: '/app/bus/banner',

}

// 查询城市列表
export const querySeviceList = params => Request.get(API.queryList, {
	data: params
})

// 首页列表（类目）
export const getServiceByArea = params => Request.get(API.getServiceByArea, {
	params
});

// 首页列表
export const getSevItemList = params => {
	// 处理数组参数
	const processedParams = {
		...params
	};
	if (Array.isArray(processedParams.itemIds)) {
		processedParams.itemIds = processedParams.itemIds.join(',');
	}
	return Request.get(API.getSevItemList, {
		params: processedParams
	});
};

// 首页列表详情页
export const getSevItemInfo = (id, params = {}) => {
	// 替换路径里的 {id} 为实际传入的 id 值 
	const url = API.getSevItemInfo.replace('{id}', id);
	return Request.get(url, {
		params
	});
};

// 新增的首页轮播图列表接口封装
export const getBannerList = params => Request.get(API.getBannerList, {
	params
});

